{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# H- with GVB\n",
    "\n",
    "GVB works for H2, including proper dissociation. But H- is giving a higher energy using GVB than using HF. I suspect there's a sign problem somewhere, but it's hard to see how such a problem wouldn't also affect H2."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "from pyquante2.scf.mcscf import gvb\n",
    "from pyquante2.geo.samples import h\n",
    "from pyquante2.geo.molecule import molecule\n",
    "from pyquante2.basis.basisset import basisset\n",
    "from pyquante2.orbman import orbman\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-0.466581845469\n"
     ]
    }
   ],
   "source": [
    "Eh = gvb(h)\n",
    "print Eh"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "**** PyQuante GVB ****\n",
      "Stoichiometry = H, Charge = -1, Multiplicity = 1\n",
      "1 H     0.000000     0.000000     0.000000\n",
      "Nuclear repulsion energy: 0.000\n",
      "Basis set: 6-31g\n",
      "  ncore/open/pair: 1,0,0\n",
      "  occ/bf/orb: 1,2,2\n",
      "Shell 0\n",
      "  occupation = 1.00\n",
      "  orbitals in shell [0]\n",
      "  couplings to other shells [(2.0, -1.0)]\n",
      "Starting guess at orbitals:\n",
      "[[-0.4274  1.2578]\n",
      " [-0.6654 -1.1498]]\n",
      "Shell array: [0]\n",
      "****\n",
      "ROTION Delta Matrix\n",
      "[[ 0.]]\n",
      "---- 1 :     -0.3678     0.0000    -0.4982     0.6287\n",
      "ROTION Delta Matrix\n",
      "[[ 0.]]\n",
      "---- 2 :     -0.4217     0.0000    -0.4821     0.5424\n",
      "ROTION Delta Matrix\n",
      "[[ 0.]]\n",
      "---- 3 :     -0.4224     0.0000    -0.4782     0.5340\n",
      "ROTION Delta Matrix\n",
      "[[ 0.]]\n",
      "---- 4 :     -0.4224     0.0000    -0.4777     0.5330\n",
      "ROTION Delta Matrix\n",
      "[[ 0.]]\n",
      "---- 5 :     -0.4224     0.0000    -0.4777     0.5329\n",
      "Energy converged\n",
      "HF energy:  -0.42244192371\n",
      "**** PyQuante GVB ****\n",
      "Stoichiometry = H, Charge = -1, Multiplicity = 1\n",
      "1 H     0.000000     0.000000     0.000000\n",
      "Nuclear repulsion energy: 0.000\n",
      "Basis set: 6-31g\n",
      "  ncore/open/pair: 0,0,1\n",
      "  occ/bf/orb: 2,2,2\n",
      "Shell 0\n",
      "  occupation = 1.00\n",
      "  orbitals in shell [0]\n",
      "  couplings to other shells [(1.0, 0.0), (0.0, -0.0)]\n",
      "Shell 1\n",
      "  occupation = 0.00\n",
      "  orbitals in shell [1]\n",
      "  couplings to other shells [(0.0, -0.0), (0.0, 0.0)]\n",
      "Starting guess at orbitals:\n",
      "[[ 0.2386  1.3068]\n",
      " [ 0.8267 -1.0399]]\n",
      "Shell array: [0, 1]\n",
      "****\n",
      "ROTION Delta Matrix\n",
      "[[  0.0000e+00   4.4371e-06]\n",
      " [ -4.4371e-06   0.0000e+00]]\n",
      "GVB CI Matrix for pair 0\n",
      "[[-0.4224  0.1361]\n",
      " [ 0.1361  1.6597]]\n",
      "GVB CI Eigenvector for pair 0\n",
      "[[-0.9979  0.0649]\n",
      " [ 0.0649  0.9979]]\n",
      "GVB CI Eigenvalues for pair 0\n",
      "[-0.4313  1.6685]\n",
      "---- 1 :     -0.4224     0.0000    -0.4777     0.5329\n",
      "ROTION Delta Matrix\n",
      "[[ 0.      0.0052]\n",
      " [-0.0052  0.    ]]\n",
      "GVB CI Matrix for pair 0\n",
      "[[-0.4209  0.1375]\n",
      " [ 0.1375  1.6592]]\n",
      "GVB CI Eigenvector for pair 0\n",
      "[[-0.9978  0.0657]\n",
      " [ 0.0657  0.9978]]\n",
      "GVB CI Eigenvalues for pair 0\n",
      "[-0.43    1.6683]\n",
      "---- 2 :     -0.3960     0.0000    -0.4738     0.5515\n",
      "ROTION Delta Matrix\n",
      "[[  0.0000e+00   6.4344e-05]\n",
      " [ -6.4344e-05   0.0000e+00]]\n",
      "GVB CI Matrix for pair 0\n",
      "[[-0.4224  0.135 ]\n",
      " [ 0.135   1.6618]]\n",
      "GVB CI Eigenvector for pair 0\n",
      "[[-0.9979  0.0644]\n",
      " [ 0.0644  0.9979]]\n",
      "GVB CI Eigenvalues for pair 0\n",
      "[-0.4311  1.6705]\n",
      "---- 3 :     -0.3957     0.0000    -0.4722     0.5488\n",
      "ROTION Delta Matrix\n",
      "[[ 0.     -0.0001]\n",
      " [ 0.0001  0.    ]]\n",
      "GVB CI Matrix for pair 0\n",
      "[[-0.4224  0.1349]\n",
      " [ 0.1349  1.6618]]\n",
      "GVB CI Eigenvector for pair 0\n",
      "[[-0.9979  0.0643]\n",
      " [ 0.0643  0.9979]]\n",
      "GVB CI Eigenvalues for pair 0\n",
      "[-0.4311  1.6705]\n",
      "---- 4 :     -0.3964     0.0000    -0.4724     0.5483\n",
      "ROTION Delta Matrix\n",
      "[[  0.0000e+00  -2.4002e-06]\n",
      " [  2.4002e-06   0.0000e+00]]\n",
      "GVB CI Matrix for pair 0\n",
      "[[-0.4224  0.1349]\n",
      " [ 0.1349  1.6618]]\n",
      "GVB CI Eigenvector for pair 0\n",
      "[[-0.9979  0.0643]\n",
      " [ 0.0643  0.9979]]\n",
      "GVB CI Eigenvalues for pair 0\n",
      "[-0.4311  1.6705]\n",
      "---- 5 :     -0.3964     0.0000    -0.4724     0.5484\n",
      "ROTION Delta Matrix\n",
      "[[  0.0000e+00   2.0118e-06]\n",
      " [ -2.0118e-06   0.0000e+00]]\n",
      "GVB CI Matrix for pair 0\n",
      "[[-0.4224  0.1349]\n",
      " [ 0.1349  1.6618]]\n",
      "GVB CI Eigenvector for pair 0\n",
      "[[-0.9979  0.0643]\n",
      " [ 0.0643  0.9979]]\n",
      "GVB CI Eigenvalues for pair 0\n",
      "[-0.4311  1.6705]\n",
      "---- 6 :     -0.3964     0.0000    -0.4724     0.5484\n",
      "ROTION Delta Matrix\n",
      "[[  0.0000e+00   6.9435e-08]\n",
      " [ -6.9435e-08   0.0000e+00]]\n",
      "GVB CI Matrix for pair 0\n",
      "[[-0.4224  0.1349]\n",
      " [ 0.1349  1.6618]]\n",
      "GVB CI Eigenvector for pair 0\n",
      "[[-0.9979  0.0643]\n",
      " [ 0.0643  0.9979]]\n",
      "GVB CI Eigenvalues for pair 0\n",
      "[-0.4311  1.6705]\n",
      "---- 7 :     -0.3964     0.0000    -0.4724     0.5484\n",
      "Energy converged\n",
      "GVB energy:  -0.396413608886\n",
      "Orbital 0 after HF\n",
      "    0.2386  H0 s\n",
      "    0.8267  H0 s\n",
      "  GVB\n",
      "    0.2318  H0 s\n",
      "    0.8321  H0 s\n",
      "Orbital 1 after HF\n",
      "    1.3068  H0 s\n",
      "   -1.0399  H0 s\n",
      "  GVB\n",
      "    1.3081  H0 s\n",
      "   -1.0356  H0 s\n"
     ]
    }
   ],
   "source": [
    "h_m = molecule(atomlist = [(1,0,0,0)],charge=-1,name=\"H-\")\n",
    "E,orbs = gvb(h_m,maxiter=10,basisname='6-31g',npair=0,verbose=True,\n",
    "             return_orbs=True)\n",
    "print \"HF energy: \", E\n",
    "o_hf = orbman(orbs,basisset(h_m,'6-31g'),h_m)\n",
    "E,orbs = gvb(h_m,maxiter=10,basisname='6-31g',npair=1,verbose=True,\n",
    "             return_orbs=True,input_orbs=orbs)\n",
    "print \"GVB energy: \", E\n",
    "o_gvb = orbman(orbs,basisset(h_m,'6-31g'),h_m)\n",
    "\n",
    "for i in [0,1]:\n",
    "    print(\"Orbital %d after HF\" % i)\n",
    "    o_hf[i]\n",
    "    print(\"  GVB\")\n",
    "    o_gvb[i]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
